//package com.mydemo.springlearning.common.conf;
//
//import com.baomidou.mybatisplus.core.MybatisConfiguration;
//import com.baomidou.mybatisplus.core.config.GlobalConfig;
//import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
//import org.springframework.context.ConfigurableApplicationContext;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.util.StringUtils;
//
//import javax.sql.DataSource;
//import java.util.Properties;
//
//@Configuration
//public class MybatisConfig {
//    @Autowired
//    ConfigurableApplicationContext context;
//
//    /**
//     * 这里全部使用mybatis-autoconfigure 已经自动加载的资源。不手动指定
//     * 配置文件和mybatis-boot的配置文件同步
//     * @return
//     */
//    @Bean
//    @ConditionalOnMissingBean
//    public SqlSessionFactory db1SqlSessionFactory(DataSource dataSource, @Qualifier("globalConfig") GlobalConfig globalConfig, Properties properties) throws Exception {
//        /**
//         * 使用 mybatis plus 配置
//         */
//        MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
//        System.out.println("dataSource:" + dataSource.toString());
//        sqlSessionFactoryBean.setDataSource(dataSource);
//        MybatisConfiguration configuration = new MybatisConfiguration();
//        sqlSessionFactoryBean.setConfiguration(configuration);
//        return sqlSessionFactoryBean.getObject();
//    }
//}